package com.ironman.imes.device.data.source;

import com.ironman.imes.device.event.EventTopic;
import com.ironman.imes.device.event.model.DeviceSourceData;
import com.ironman.imes.device.framework.base.threadpool.ThreadPool;
import org.noear.dami.Dami;

import java.util.concurrent.Future;

public interface BaseSource {

    default void launchData(DeviceSourceData deviceSourceData) {
        Future<?> future = ThreadPool.SOURCE_FIXED_EXECUTOR.submit(() -> {
            Dami.<DeviceSourceData, Void>bus().send(EventTopic.DEVICE_SOURCE_DATA_TOPIC, deviceSourceData);
        });
        try {
            future.get();
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}
